<?php

class D_Errors {
	private $_errors = array();
	private $_field_error = array();
	
	//add array of error
	function adds($error_array,$field_name='',$field_name2=''){
		$this->_errors = array_merge($this->_errors,$error_array);
		if(count($error_array)>0){
			if(!in_array($field_name, $this->_field_error) && $field_name != '')
				$this->_field_error[] = $field_name;
			if(!in_array($field_name2, $this->_field_error) && $field_name2 != '')
				$this->_field_error[] = $field_name2;	
		}
	}
	//add error
	function add($error,$field_name=''){
		$this->_errors[] = $error;
		if($field_name != ''){
			if(!in_array($field_name, $this->_field_error))
				$this->_field_error[] = $field_name;
		}
	}
	
	//get all errors
	function gets(){
		return $this->_errors;
	}
	
	function addFieldError($field_name){
		if(!in_array($field_name,$this->_field_error))
			$this->_field_error[] = $field_name;
	}
	
	function getFieldErrors(){
		return $this->_field_error;
	}
	
	function total(){
		return count($this->_errors);
	}
	
}

?>